package com.hoaptt.pieces;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import com.hoaptt.helper.Coordinate;
import com.hoaptt.model.Board;
import java.util.ArrayList;

/**
 *
 * @author ThuHoa
 */
public class Elephant extends Piece {

    public Elephant(PLAYER player) {
        super(player);

        this.nameA = Character.toString((char) 30456);
        this.nameB = Character.toString((char) 35937);
        this.alias = Piece.NAMEPIECE.elephant;
    }

    @Override
    public ArrayList<Coordinate> generateMove(Board board, Coordinate loc) {
        ArrayList<Coordinate> ar = new ArrayList<Coordinate>();
        int X[] = new int[]{2, 2, -2, -2};
        int Y[] = new int[]{-2, 2, 2, -2};
        for (int i = 0; i < X.length; i++) {
            Coordinate coo = new Coordinate(loc.getRow() + X[i], loc.getCol() + Y[i]);
            System.out.println("Coor: " + coo.getRow() + "\t" + coo.getCol());
            // kiem tra co bi can hay khong
            Coordinate medium = new Coordinate((loc.getRow() + coo.getRow()) / 2, (loc.getCol() + coo.getCol()) / 2);
            if (board.getAtLoc(loc).player == Piece.PLAYER.A) {
                //Player A, column <=4 de ko sang song duoc
                if (board.getAtLoc(coo) != null && coo.getCol() <= 4) {
                    if (board.getAtLoc(medium).getAlias() == Piece.NAMEPIECE.default1
                            || board.getAtLoc(medium).getAlias() == null) {
                        ar.add(coo);
                    }
                }
            }
            if (board.getAtLoc(loc).player == Piece.PLAYER.B) {
                //Player A, column <=4 de ko sang song duoc
                if (board.getAtLoc(coo) != null && coo.getCol() >= 4) {
                    if (board.getAtLoc(medium).getAlias() == Piece.NAMEPIECE.default1
                            || board.getAtLoc(medium).getAlias() == null) {
                        ar.add(coo);
                    }
                }
            }
        }
        return ar;
    }
}
